home *** CD-ROM | disk | FTP | other *** search
/ The Sunday Times: The Month 2004 August / The Sunday Times - The Month 2004-08.iso / pc / engine / shell / shell.swf / scripts / frame_3 / DoAction_3.as < prev    next >
Encoding:
Text File  |  2004-07-06  |  11.8 KB  |  463 lines

  1. function makeButtonShield()
  2. {
  3.    var clp = this.createEmptyMovieClip("mc_button_shield",Tardis.depth++);
  4.    var clpHA = clp.createEmptyMovieClip("mc_hitarea",Tardis.depth++);
  5.    var w = 250;
  6.    var h = 50;
  7.    clpHA.moveTo(0,0);
  8.    clpHA.beginFill(16711680);
  9.    clpHA.lineTo(w,0);
  10.    clpHA.lineTo(w,h);
  11.    clpHA.lineTo(0,h);
  12.    clpHA.lineTo(0,0);
  13.    clpHA.endFill();
  14.    clp._x = _xmouse - w / 2;
  15.    clp._y = _ymouse - h / 2;
  16.    clp.hitArea = clpHA;
  17.    clp.onRollOut = function()
  18.    {
  19.       this.mc_hitarea.removeMovieClip();
  20.       this.removeMovieClip();
  21.    };
  22.    clpHA._visible = false;
  23. }
  24. function splashRestart()
  25. {
  26.    if(ActiveSection == null)
  27.    {
  28.       trace("restart her");
  29.       Tardis.splash.startSoundLoop();
  30.       return undefined;
  31.    }
  32.    LastSection = ActiveSection;
  33.    ActiveSection = null;
  34.    bottomNav.show();
  35.    bottomNav.clearActive();
  36.    bottomNav.fadeOthers("","up");
  37.    footer.sponsorButtonShow();
  38.    if(ActiveItem != null)
  39.    {
  40.       LastItem = ActiveItem;
  41.       itemExit();
  42.    }
  43.    else if(LastSection.type == "bespoke")
  44.    {
  45.       itemExit();
  46.    }
  47.    header.clearUp();
  48. }
  49. function webPageOpen(strURL)
  50. {
  51.    if(PLAY_MODE == "browser")
  52.    {
  53.       getURL(strURL,"");
  54.    }
  55.    else if(ActiveSection.confirmweb != null)
  56.    {
  57.       lingo("Flsh_openWebPageConfirm(\"" + strURL + "\")");
  58.    }
  59.    else
  60.    {
  61.       lingo("Flsh_openWebPage(\"" + strURL + "\")");
  62.    }
  63. }
  64. function sectionGo()
  65. {
  66.    if(splash.blnAtStart == true)
  67.    {
  68.       delete splash.blnAtStart;
  69.       header.go(ActiveSection.id);
  70.       sectionLoad();
  71.    }
  72.    else
  73.    {
  74.       sectionLoad();
  75.    }
  76. }
  77. function sectionLoad()
  78. {
  79.    LastSection = null;
  80.    var strID = ActiveSection.id;
  81.    if(ActiveSection.type == "bespoke")
  82.    {
  83.       trace("ActiveSection.type = bespoke");
  84.       template.loadBespokeSection();
  85.       UsageData.addPageEntry(ActiveSection.index);
  86.       header.go(ActiveSection.id);
  87.    }
  88.    else
  89.    {
  90.       sideMenu.onComplete = function()
  91.       {
  92.          delete this.onComplete;
  93.          template.loadModules();
  94.       };
  95.       template.onDataLoaded = function()
  96.       {
  97.          delete this.onDataLoaded;
  98.          this.loadModules();
  99.       };
  100.       sideMenu.onReady = function()
  101.       {
  102.          this._visible = true;
  103.          this.onReady = null;
  104.          if(Shortcut != null)
  105.          {
  106.             header.go(ActiveSection.id);
  107.             Tardis.ActiveItem = this.ItemHome.byPath(Shortcut);
  108.             if(Tardis.ActiveItem == null)
  109.             {
  110.                Tardis.ActiveItem = this.ItemHome;
  111.             }
  112.             this.makeChildren(Tardis.ActiveItem);
  113.             Tardis.itemLoad();
  114.             delete Shortcut;
  115.          }
  116.          else if(Tardis.ActiveItem == null)
  117.          {
  118.             Tardis.ActiveItem = this.ItemHome;
  119.             Tardis.itemLoad();
  120.          }
  121.       };
  122.       sideMenu.make(strID);
  123.    }
  124.    if(ActiveSection.hideSponsor == "true")
  125.    {
  126.       footer.sponsorButtonHide();
  127.    }
  128.    else
  129.    {
  130.       footer.sponsorButtonShow();
  131.    }
  132. }
  133. function sectionExit()
  134. {
  135.    ActiveItem = null;
  136.    LastItem = null;
  137.    sideMenu.clearUp();
  138.    adverts.clearUp();
  139.    if(Shortcut != null)
  140.    {
  141.       sectionLoad();
  142.    }
  143.    else if(ActiveSection != null)
  144.    {
  145.       sectionGo();
  146.    }
  147.    else
  148.    {
  149.       splash.show();
  150.       splash.restart();
  151.    }
  152. }
  153. function itemJump(nmSection, strPath)
  154. {
  155.    splash.interrupted = false;
  156.    var objSectionNew = Sections.item(nmSection);
  157.    if(overlay.active == true)
  158.    {
  159.       template.onReady = function()
  160.       {
  161.          Tardis.overlay.close();
  162.          this.onReady = null;
  163.       };
  164.    }
  165.    if(objSectionNew != ActiveSection)
  166.    {
  167.       LastSection = ActiveSection;
  168.       ActiveSection = objSectionNew;
  169.       Shortcut = strPath;
  170.       bottomNav.setActive(ActiveSection.id);
  171.       if(LastSection == null)
  172.       {
  173.          sectionLoad();
  174.       }
  175.       else
  176.       {
  177.          itemExit();
  178.       }
  179.    }
  180.    else
  181.    {
  182.       ActiveItem = sideMenu.ItemHome.byPath(strPath);
  183.       sideMenu.makeChildren(ActiveItem);
  184.       itemLoad();
  185.    }
  186. }
  187. function itemGo(Item)
  188. {
  189.    switch(Item.attributes.type)
  190.    {
  191.       case "html":
  192.          if(Childlock.active == true)
  193.          {
  194.             return undefined;
  195.          }
  196.          var strURL = Item.attributes.local != "true" ? "" : "assets/html/";
  197.          strURL += Item.attributes.file;
  198.          webPageOpen(strURL);
  199.          itemLog(Item);
  200.          break;
  201.       case "lock":
  202.          if(Childlock.active != true)
  203.          {
  204.             Childlock.lockDialog();
  205.          }
  206.          else
  207.          {
  208.             Childlock.unlockDialog();
  209.          }
  210.          break;
  211.       case "app":
  212.          itemLog(Item);
  213.          break;
  214.       case "shortcut":
  215.          itemJump(Item.attributes.section,Item.attributes.itemref);
  216.          break;
  217.       case "promo":
  218.          var promoID = Item.attributes.promoid;
  219.          var obj = {filename:Tardis.Settings.promos[Tardis.ActiveSection.id][promoID].filename,category:Tardis.Settings.promos[Tardis.ActiveSection.id][promoID].category,closeBut:"promo"};
  220.          Tardis.OverlayController.addOverlay(obj);
  221.          var SECTION_NUM = Tardis.ActiveSection.index;
  222.          var PLAYLIST_NUM = 1;
  223.          var strLog = SECTION_NUM + "." + PLAYLIST_NUM;
  224.          var strType = "promo";
  225.          Tardis.UsageData.addAdvertEntry(strLog,strType);
  226.          break;
  227.       case "semiOverlay":
  228.          var theXmlFile = Tardis.ASSETS_FOLDER + "xml/content/kids/" + Item.attributes.xmlfile + ".xml";
  229.          overlay = new XML();
  230.          overlay.ignoreWhite = true;
  231.          overlay.onLoad = function(success)
  232.          {
  233.             if(success)
  234.             {
  235.                var cartoon = this.firstChild.firstChild.byName("cartoon");
  236.                var f = cartoon.byName("filename");
  237.                var c = cartoon.byName("category");
  238.                var obj = {filename:f.firstChild.nodeValue,category:c.firstChild.nodeValue,disableLevel:1,strType:"bespoke",closeBut:""};
  239.                Tardis.OverlayController.addOverlay(obj);
  240.             }
  241.             else
  242.             {
  243.                trace("!! XML load failed !!");
  244.             }
  245.          };
  246.          overlay.load(theXmlFile);
  247.          break;
  248.       default:
  249.          break;
  250.       case "template":
  251.       case "bespoke":
  252.          LastItem = ActiveItem;
  253.          ActiveItem = Item;
  254.          if(LastItem != null)
  255.          {
  256.             itemExit();
  257.          }
  258.          else
  259.          {
  260.             itemLoad();
  261.          }
  262.          return true;
  263.    }
  264. }
  265. function itemLoad()
  266. {
  267.    Tardis.debug.addProcess("loadModules","Tardis : itemLoad()");
  268.    sideMenu.onComplete = function()
  269.    {
  270.       Tardis.debug.addProcess("loadModules","sideMenu.onComplete()");
  271.       Tardis.debug.addProcess("loadModules","load the modules...");
  272.       delete this.onComplete;
  273.       template.loadModules();
  274.    };
  275.    template.onDataLoaded = function()
  276.    {
  277.       delete this.onDataLoaded;
  278.       this.loadModules();
  279.    };
  280.    if(ActiveSection.hideSponsor != "true" || ActiveItem.attributes.hideSponsor == "false")
  281.    {
  282.       footer.sponsorButtonShow();
  283.    }
  284.    else
  285.    {
  286.       footer.sponsorButtonHide();
  287.    }
  288.    template.load();
  289.    itemLog(ActiveItem);
  290. }
  291. function loadAdvertButton()
  292. {
  293.    Tardis.debug.addProcess("loadModules","Tardis.loadAdvertButton()");
  294.    Tardis.debug.showProcessPath("loadModules");
  295.    Tardis.debug.clearProcessPath("loadModules");
  296.    var item_advert = ActiveItem.attributes.advert;
  297.    var advert_id = item_advert != null ? item_advert : ActiveSection.advert;
  298.    if(advert_id != adverts.strPlaylistID)
  299.    {
  300.       adverts.prepare(advert_id);
  301.    }
  302. }
  303. function itemExit()
  304. {
  305.    Tardis.debug.addProcess("clickMainNav","Tardis : itemExit()");
  306.    template.exit();
  307. }
  308. function itemHide()
  309. {
  310.    if(ActiveItem.attributes.type === "template")
  311.    {
  312.       template.hide();
  313.    }
  314. }
  315. function itemShow()
  316. {
  317.    if(ActiveItem.attributes.type === "template")
  318.    {
  319.       template.show();
  320.    }
  321. }
  322. function itemLog(Item)
  323. {
  324.    var str = ActiveSection.index;
  325.    if(Item != sideMenu.ItemHome)
  326.    {
  327.       str += sideMenu.arrParentIndex.length <= 0 ? "" : "." + sideMenu.arrParentIndex.join(".");
  328.       str += Item.firstChild.hasChildNodes() == true ? "" : "." + Item.index;
  329.    }
  330.    Tardis.UsageData.addPageEntry(str);
  331. }
  332. function onItemExit()
  333. {
  334.    Tardis.debug.addProcess("clickMainNav","Tardis : onItemExit()");
  335.    if(LastSection != null)
  336.    {
  337.       LastSection = null;
  338.       sectionExit();
  339.    }
  340.    else
  341.    {
  342.       itemLoad();
  343.    }
  344. }
  345. function maskShow()
  346. {
  347.    this.attachMovie("clp_fullscreen_mask","mask",Tardis.depth++);
  348.    TardisInterface.disable();
  349. }
  350. function maskHide()
  351. {
  352.    mask.removeMovieClip();
  353.    TardisInterface.enable();
  354. }
  355. findAndReplace = function(strStr, strSearch, strReplace)
  356. {
  357.    var i = 0;
  358.    var l = strStr.length;
  359.    var strTemp;
  360.    while(i < l)
  361.    {
  362.       if(strStr.charAt(i) == strSearch)
  363.       {
  364.          strTemp += strReplace;
  365.       }
  366.       else
  367.       {
  368.          strTemp += strStr.charAt(i);
  369.       }
  370.       i++;
  371.    }
  372.    return strTemp;
  373. };
  374. bottomNav.onOver = function(strID)
  375. {
  376.    with(Tardis)
  377.    {
  378.       SFX.play("NavOver");
  379.       if(ActiveSection == null)
  380.       {
  381.          splash.pauseAt(strID);
  382.       }
  383.    }
  384. };
  385. bottomNav.onOut = function()
  386. {
  387.    with(Tardis)
  388.    {
  389.       if(ActiveSection == null)
  390.       {
  391.          splash.resume();
  392.       }
  393.    }
  394. };
  395. bottomNav.onUp = function(strID)
  396. {
  397.    Tardis.debug.addProcess("clickMainNav","Tardis : bottomNav : onUp()");
  398.    with(Tardis)
  399.    {
  400.       if(splash.onAnimationEnd != null && ActiveSection != null)
  401.       {
  402.          bottomNav.setActive(ActiveSection.id);
  403.          Tardis.debug.addProcess("clickMainNav","Tardis : bottomNav : onUp() : setActive : " + ActiveSection.id);
  404.          return undefined;
  405.       }
  406.       SFX.play("NavClick");
  407.       var blnAtFirstSplash = ActiveSection == null;
  408.       LastSection = ActiveSection;
  409.       ActiveSection = Tardis.Sections[strID];
  410.       if(blnAtFirstSplash)
  411.       {
  412.          Tardis.debug.addProcess("clickMainNav","Tardis : bottomNav : onUp() : blnAtFirstSplash : " + blnAtFirstSplash);
  413.          if(PLAY_MODE != "browser")
  414.          {
  415.             Tardis.debug.addProcess("clickMainNav","Tardis : bottomNav : onUp() : adding splash callback (onAnimationEnd())");
  416.             splash.onAnimationEnd = function()
  417.             {
  418.                this.endSoundLoop();
  419.                this.onAnimationEnd = null;
  420.                this.clearUp();
  421.                this.blnAtStart = true;
  422.                Tardis.sectionGo();
  423.                Tardis.debug.addProcess("clickMainNav","Tardis : splash : onAnimationEnd() : now calling Tardis.sectionGo()");
  424.             };
  425.             splash.resume();
  426.          }
  427.          else
  428.          {
  429.             mc_browser_msg.unloadMovie();
  430.             splash.blnAtStart = true;
  431.          }
  432.       }
  433.       else
  434.       {
  435.          Tardis.debug.addProcess("clickMainNav","Tardis : bottomNav : onUp() : blnAtFirstSplash : " + blnAtFirstSplash);
  436.          Tardis.debug.addProcess("clickMainNav","Tardis : bottomNav : onUp() : strID : " + strID);
  437.          if(strID != LastSection.id)
  438.          {
  439.             if(LastSection.type != "bespoke")
  440.             {
  441.                LastItem = ActiveItem;
  442.             }
  443.             header.go(strID);
  444.             Tardis.debug.addProcess("clickMainNav","Tardis : bottomNav : onUp() : calling itemExit()");
  445.             itemExit();
  446.          }
  447.          else
  448.          {
  449.             if(LastSection.type != "bespoke")
  450.             {
  451.                Tardis.debug.addProcess("clickMainNav","PATH ENDS PREMATURELY HERE");
  452.                Tardis.debug.showProcessPath("clickMainNav");
  453.                if(ActiveItem != sideMenu.ItemHome)
  454.                {
  455.                   itemGo(sideMenu.ItemHome);
  456.                }
  457.             }
  458.             LastSection = null;
  459.          }
  460.       }
  461.    }
  462. };
  463.